//
//  ViewController.m
//  block深入浅出
//
//  Created by 周冰烽 on 2021/5/17.
//

#import "ViewController.h"
#import "BlockViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)test {
    // __NSGlobalBlock__
    void (^block1)(void) = ^{
        NSLog(@"123");
    };
    block1();
    NSLog(@"%@", block1);
    // __NSMallocBlock__
    int a = 10;
    void (^block2)(void) = ^{
        NSLog(@"%d", a);
    };
    block2();
    NSLog(@"%@", block2);
    // __NSStackBlock__
    // 注意: xcode12后打印出的为 __NSMallocBlock__, 之前的打印为__NSStackBlock__
    int b = 20;
    NSLog(@"%@", ^{
        NSLog(@"%d", b);
    });
    // __NSStackBlock__
    int c = 30;
    void (^ __weak block3)(void) = ^{
        NSLog(@"%d", c);
    };
    block3();
    NSLog(@"%@", block3);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    BlockViewController *blockVC = [[BlockViewController alloc] init];
    [self.navigationController pushViewController:blockVC animated:YES];
}



@end
